#include"comm.h"
#include<unistd.h>
int main()
{
  key_t key=ftok(PATH_NAME,PROJ_ID);
  if(key<0){
    perror("ftok");
    return 1;
  }

  printf("%u\n",key);
  int shmid=shmget(key,SIZE,IPC_CREAT);
  if(shmid<0){
    perror("shmid");
    return 1;
  }
  
  //attach
  char *men=(char *)shmat(shmid,NULL,0);
  sleep(5);
  printf("client process attaches success\n");

  //通信
  char c='A';
  while(c<='Z'){
    men[c-'A']=c;
    c++;
    men[c-'A']=0;
    sleep(2);
  }

  //detaches
  shmdt(men);
  printf("client process detaches succsee\n");
  return 0;
}
